from dotenv import load_dotenv
load_dotenv()
from langgraph.graph import StateGraph, END
from graph.nodes import ExtractTextNode, GenerateHtmlNode, AnalysisContentNode

def create_flow():
    """使用 LangGraph 创建处理流程"""

    # 创建节点
    extract_text = ExtractTextNode()
    analysis_content = AnalysisContentNode()
    gen_results = GenerateHtmlNode()

    # 创建 StateGraph
    builder = StateGraph()

    # 添加节点
    builder.add_node("extract_text", extract_text)
    builder.add_node("analysis_content", analysis_content)
    builder.add_node("gen_results", gen_results)

    # 连接节点
    builder.add_edge("extract_text", "analysis_content")
    builder.add_edge("analysis_content", "gen_results")
    builder.add_edge("gen_results", END)

    # 设置起始节点
    builder.set_entry_point("extract_text")

    # 构建并返回流程
    return builder.compile()